{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "91ec30da-68dd-443f-90a7-e2a9304c3067",
   "metadata": {},
   "source": [
    "Chapter 07\n",
    "# 使用numpy.dot() 计算向量内积\n",
    "Book_1《编程不难》 | 鸢尾花书：从加减乘除到机器学习 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "4816820a-724f-49ab-ad11-01485603b2f0",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "\n",
    "# 定义向量a和b；准确来说是一维数组\n",
    "a = np.array([1, 2, 3, 4, 5])\n",
    "b = np.array([6, 7, 8, 9, 0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "3d4522c5-fd8e-4312-9e2e-a1dc2a110a58",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "向量内积为： 80\n"
     ]
    }
   ],
   "source": [
    "# 计算向量内积\n",
    "dot_product = np.dot(a,b)\n",
    "\n",
    "# 打印内积\n",
    "print(\"向量内积为：\", dot_product)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
